/**
 * @file
 * @description 商品模块接口文件
 */

import request from './request';

/**
 * @method
 * @description 获取商品列表
 * @param {Object} model 查询模型
 */
export const getGoodsList = (model) => request.get('goods', {
    params: model
});

/**
 * @method 
 * @description 添加商品
 * @param {Object} model  要添加商品的数据
 */
export const addGoods = (model) => request.post('goods', model);
;
/**
 * @method 
 * @description 修改商品
 * @param {Object} model  要修改商品的数据
 */
export const updateGoods = (model) => request.put('goods/' + model.goods_id, model);

/**
 * @method
 * @description 获取分类参数
 * @returns 
 */
export const getCategories = () => request.get('categories');

/**
 * @description 获取参数列表
 * @method
 * @param {Number} id  分类Id
 * @param {*} type  类型
 * @returns 
 */
export const getAttributes = (id, type) => request.get(`categories/${id}/attributes?sel=${type}`);


/**
 * @description 添加属性
 * @param {Number} id  分类Id
 * @param {Object} model 要添加的属性模型
 * @returns 
 */
export const addAttributes = (id, model) => request.post(`categories/${id}/attributes`, model);


/**
 * @description 修改属性
 * @param {Number} id  分类Id
 * @param {Object} model 要添加的属性模型
 * @returns 
 */
export const updateAttributes = (id, model) => request.put(`categories/${id}/attributes/${model.attr_id}`, model);

/**
 * @method 
 * @param {Number} id 分类Id
 * @param {Number} catId  属性Id
 * @description 删除属性 categories/73/attributes/3978
 */
export const deleteAttributes = (id, attrId) => request.delete(`categories/${id}/attributes/${attrId}`);